package com.own.business.wallet.entity.vo;

import com.own.business.wallet.entity.po.WalletHistory;
import com.own.component.common.base.entity.vo.BaseVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * WalletHistoryVo
 *
 * @author chenxueli
 * @date 2023-08-28 16:05:10
 */
@Schema(title = "钱包订单流水" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class WalletHistoryVo extends BaseVo<WalletHistory> implements Serializable {

    @Schema(title = "用户id")
    private Long userId;

    @Schema(title = "钱包id")
    private Long walletId;

    @Schema(title = "订单号")
    private String tradeNo;

    @Schema(title = "订单标题")
    private String subject;

    @Schema(title = "订单附加信息")
    private String body;

    @Schema(title = "商户订单号")
    private String outTradeNo;

    @Schema(title = "商户退款订单号")
    private String outRefundNo;

    @Schema(title = "订单总金额（分）")
    private Integer totalAmount;

    @Schema(title = "订单状态（1=新建 2=完成 4=订单关闭 5=超时取消）")
    private Integer status;

    @Schema(title = "订单过期时间")
    private LocalDateTime expireTime;

    @Schema(title = "回调地址")
    private String callback;

    @Schema(title = "支付时间")
    private LocalDateTime payTime;

    @Schema(title = "流水类型（1=收入 2=支出 3=退款）")
    private Integer type;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public WalletHistoryVo(@NonNull WalletHistory entity) {
        super(entity);
        this.userId = entity.getFkUserId();
        this.walletId = entity.getFkWalletId();
        this.tradeNo = entity.getTradeNo();
        this.subject = entity.getSubject();
        this.body = entity.getBody();
        this.outTradeNo = entity.getOutTradeNo();
        this.outRefundNo = entity.getOutRefundNo();
        this.totalAmount = entity.getTotalAmount();
        this.status = entity.getStatus();
        this.expireTime = entity.getExpireTime();
        this.callback = entity.getCallback();
        this.payTime = entity.getPayTime();
        this.type = entity.getType();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public WalletHistory toPo(WalletHistory entity) {
        if (entity == null) {
            entity = new WalletHistory();
        }
        entity.setFkUserId(this.userId);
        entity.setFkWalletId(this.walletId);
        entity.setTradeNo(this.tradeNo);
        entity.setSubject(this.subject);
        entity.setBody(this.body);
        entity.setOutTradeNo(this.outTradeNo);
        entity.setOutRefundNo(this.outRefundNo);
        entity.setTotalAmount(this.totalAmount);
        entity.setStatus(this.status);
        entity.setExpireTime(this.expireTime);
        entity.setCallback(this.callback);
        entity.setPayTime(this.payTime);
        entity.setType(this.type);
        return super.toPo(entity);
    }

}
